require('shelljs/global')
const path = require('path');
const merge = require('webpack-merge');
// 引入通用webpack配置文件
const common = require('./webpack.common.js');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
// 对js代码进行混淆压缩的插件
const uglifyJSPlugin = new UglifyJSPlugin();

// 拷贝静态文件
// var assetsPath = path.join(__dirname, '/dist/static')
// rm('-rf', assetsPath)
// mkdir('-p', assetsPath)
// cp('-R', 'src/static/*', assetsPath)

module.exports = merge(common, {
  module: {
    rules: [
      {
      test: /\.ts$/,
      exclude: /node_modules/,
      use: [
        {
          loader: 'ts-loader'
        }
      ]
    }
  ]
  },
  devtool: 'cheap-module-source-map',
  plugins: [
    uglifyJSPlugin,
  ],
  // 设置出口文件地址与文件名
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'webplayer.min.js'
  },
});
